﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DomainModel;
using Utils;
using System.ComponentModel.DataAnnotations;
using DataAnnotationsExtensions;

namespace WebUI.Models
{
    public class IndEditShotViewModel: BaseViewModel
    {
        //typically should has this
        public IndEditShotViewModel() 
            :base()
        { }

        public IndEditShotViewModel(Shot shot)
            : base(new { Shot = shot})
        { }

        [NoHtml]
        [Required]
        [StringLength(64, ErrorMessage = "The Title field has maximum 64 characters")]
        public string Title { get; set; }

        [NoHtml]
        [StringLength(500, ErrorMessage = "The Description field has maximum 500 characters")]
        public string Description { get; set; }

        public List<STag> ShotTagList { get; set; }
        public int ShotID { get; set; }
        //shot
        public Shot Shot { get; set; }
        //shot url
        public string ShotUrl { get; set; }

        protected override void SetVarsWhichDependOnDynamicParams(dynamic dynParams)
        {
            Shot = dynParams.Shot;
            ShotID = Shot.ShotID;
            Title = Shot.Title;
            Description = Shot.Description;
            ShotUrl = ImageUtils.GetShotRelativeUrl(Identity.AccountID, ShotID, ShotSizeEnum.Shot_450x300, Shot.FileExtension);
            ShotTagList = SqlUtilities.Query<STag>(ConstUtils.SP_GetShotTagListByID, new { IndID = Identity.AccountID, ShotID = ShotID }).ToList();
        }

        
    }
}